package com.zjbd.shuaiyangfile.controller;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.zjbd.shuaiyangcommoncore.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.dromara.x.file.storage.core.FileInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.dromara.x.file.storage.core.FileStorageService;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "视频上传接口")
@Slf4j
@RequestMapping("/shuaiyang/file")
@RestController
public class DyVideoFileController {
    @Autowired
    private FileStorgeService fileStorgeService;

    @Operation(summary = "上传视频")
    @PostMapping("/uploadVideo")
    public Result uploadVideo(MultipartFile file){
        //String today = DateUtil.today();
        String simpleUUID = IdUtil.simpleUUID();

        FileInfo fileInfo = fileStorgeService.of(file)
                .setPath("uploadVideo/")
                .setObjectId(simpleUUID)
                .upload();

        return Result.success(fileInfo);
    }
}
